const hitBottomHeight = 10;
export default { 
    /**
     * 监听触底滚动
     * @param {Object} e dom
     * @param {Function} fn 回调方法
     * @param {Object} pagination 分页对象
     * @param {Boolean} scrollLoading 是否已触发
     * 
     * 使用 Core.Util.scroll.handleScrollFn(e, this.getData, this.pagination, this.showLoading)
     */
    handleScrollFn(e, fn, pagination = {}, scrollLoading = false, hitBottomHeightQ = '') {
        if (!e || !fn) return;
        const element = e.target;
        if (Math.ceil(element.scrollTop + element.clientHeight) >= element.scrollHeight - (hitBottomHeightQ || 0 + hitBottomHeight)) {
            // console.log("滑到底部")
            if ((pagination.page < pagination.total_page) && !scrollLoading) {
                pagination.page ++
                fn({ page: pagination.page })
            }
        }
    }
}